package org.shj.spark.core

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.rdd.RDD.rddToOrderedRDDFunctions

object TopN {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf
    conf.setAppName("TopN").setMaster("local")
    val sc = new SparkContext(conf)
    
    val rdd = sc.textFile("E:/workspace/scala/sparkjava/src/main/resources/topN.txt")
    
    rdd.map(item => (item.toInt, item)).sortByKey(false).take(3).foreach(println)
    
    sc.stop()
  }
}